pbkdf2_sha512-sjcl.js ➔ ... ➔ this.encrypt   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
nop 0
1
var sjcl = require('sjcl');
2
3
var hmacSha512 = function(key) {
4
    var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha512);
5
    this.encrypt = function() {
6
        return hasher.encrypt.apply(hasher, arguments);
7
    };
8
};
9
10
var pbkdf2Sha512 = function(pw, salt, iterations, keySizeBytes) {
11
    salt = sjcl.codec.hex.toBits(salt.toString('hex'));
12
    var data = sjcl.codec.hex.toBits(pw.toString('hex'));
13
    return new Buffer(sjcl.codec.hex.fromBits(sjcl.misc.pbkdf2(data, salt, iterations, keySizeBytes * 8, hmacSha512)), 'hex');
0 ignored issues
show
Bug introduced by
The variable Buffer seems to be never declared. If this is a global, consider adding a /** global: Buffer */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
14
};
15
16
module.exports = {
17
    digest: pbkdf2Sha512
18
};
19